package user;

import cake.Cake;
import cake.UserDao;
import cake.UserDaoImpl;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.util.List;

@WebServlet(name = "SearchAllServlet", value = "/SearchAllServlet")
public class SearchAllServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        UserDao ud = new UserDaoImpl();
        List<Cake> cake = ud.searchAll();
        req.setAttribute("cakes",cake);
        System.out.println("查询全部用户成功");
        req.getRequestDispatcher("/showAll.jsp").forward(req, resp);
    }
}
